import App from './App'

// #ifndef VUE3
import Vue from 'vue'
import globalMethods from './common/globalMethods'
Vue.config.productionTip = false
App.mpType = 'app'
//引入uview
import uView from "uview-ui";
import theme from '@/common/style/global.js'
import Mixin from './minix/index.vue'; // 获取导航栏高度
 
Vue.mixin(Mixin); 
Vue.prototype.$theme = theme
Vue.use(uView);
Vue.use(globalMethods)
// 拦截所有到novel_plugin页面的跳转
// const originalNavigateTo = tt.navigateTo;
// tt.navigateTo = (options) => {
//   if (options.url.includes('novel_plugin')) {
//     console.warn('已禁用直接跳转到novel_plugin页面');
//     return tt.showToast({ title: '功能暂不可用', icon: 'none' });
//   }
//   return originalNavigateTo(options);
// };

try {
	function isPromise(obj) {
		return (
			!!obj &&
			(typeof obj === "object" || typeof obj === "function") &&
			typeof obj.then === "function"
		);
	}

	// 统一 vue2 API Promise 化返回格式与 vue3 保持一致
	uni.addInterceptor({
		returnValue(res) {
			if (!isPromise(res)) {
				return res;
			}
			return new Promise((resolve, reject) => {
				res.then((res) => {
					if (res[0]) {
						reject(res[0]);
					} else {
						resolve(res[1]);
					}
				});
			});
		},
	});
} catch (error) {}

const app = new Vue({
	...App
})
// 定义全局口令词
Vue.prototype.$globalData = {
  searchKeywordId: 0 
}
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif